<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml"  xmlns:th="http://www.thymeleaf.org">

	<head>
		<meta charset="UTF-8">
		<title>地址管理</title>
		<meta http-equiv="X-UA-Compatible" content="IE=edge">
		<meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
		<meta name="description" content="Write an awesome description for your new site here. You can edit this line in _config.yml. It will appear in your document head meta (for Google search results) and in your feed.xml site description.">
		<link rel="stylesheet" href="lib/weui.min.css">
		<link rel="stylesheet" href="css/jquery-weui.css">
		<link rel="stylesheet" href="css/style.css">
		<style type="text/css">
			.address-delete{
				float: right;
				right: 0px;
				margin-top: 8%;
			}
		</style>
	</head>
	<body ontouchstart>
		<!--地址管理开始-->
		<header class="wy-header">
			<div class="wy-header-icon-back" onclick="back();"><span></span></div>
			<div class="wy-header-title">地址管理</div>
		</header>
		<!--地址管理结束-->
		<!--主体开始-->
		<div th:if="${orderid!=null}">
			<input type="hidden" th:value="${orderid}" class="orderid"/>
		</div>
		<div class="weui-content" th:if="${listaddress!=null}">
			<!--地址主体开始-->
			<div class="weui-panel address-box">
				<!--默认地址开始部分-->
				<div class="weui-panel__bd" th:each="list:${listaddress}" th:name="${list.id}" onclick="ChooseAddress(this)">
					<div class="weui-media-box weui-media-box_text address-list-box" >
						<a onclick="abc(this)" th:name="${list.id}" class="address-edit"></a>
						<a onclick="def(this)" th:id="${list.id}"><img src="images/icon-dele.png" class="address-delete" width="9%" height="9%"/></a>
						<h4 class="weui-media-box__title"><span th:text="${list.consignee}"></span><span th:text="${list.phone}"></span></h4>
						<p class="weui-media-box__desc address-txt" th:text="${list.address}"></p>
						<span class="default-add" th:if="${list.defaultAddress}=='是'">默认地址</span>
					</div>
				</div>

				<!--默认地址结束部分-->
				<!--地址开始部分-->
				<!--<div class="weui-media-box weui-media-box_text address-list-box" th:if="${listaddress.size()!=1}" th:each="list:${listaddress}">
					<a href="address_edit.html" class="address-edit"></a>
					<h4 class="weui-media-box__title"><span th:text="${list.consignee}"></span><span th:text="${list.phone}"></span></h4>
					<p class="weui-media-box__desc address-txt" th:text="${list.address}"></p>
				</div>-->
				<!--地址结束部分-->
			</div>
			<!--地址主体结束-->
		</div>
		<!--主体结束-->
		<!--添加收货地址开始-->
		<div class="weui-btn-area">
			<!--点击跳转到添加收货地址页面-->
			<a class="weui-btn weui-btn_primary" href="Address.htm" id="showTooltips">添加收货地址</a>
		</div>
		<!--添加收货地址结束-->
	</body>
	<script src="lib/jquery-2.1.4.js"></script>
	<script src="lib/fastclick.js"></script>
	<script type="text/javascript" src="js/jquery.Spinner.js"></script>
	<script>
		$(function() {
			FastClick.attach(document.body);
		});
	</script>
	<script src="js/jquery-weui.js"></script>
	<script type="text/javascript" src="js/layer/layer.js"></script>
<script>
	//修改地址触发的方法
    function abc(a) {
		var uid= $(a).attr("name");
		window.location.href="getUpdateAddress.htm?uid="+uid;
    }
</script>
<script>
	//删除地址的方法
        function def(b) {
            var did= $(b).attr("id");
            $.ajax({
				url:"deleteAddress.htm?did="+did,
				post:"post",
				success:function (message) {
					if(message==1){
					    layer.msg("删除成功！");
                        window.location.href="GetAllAddress.htm";
					}else{
                        layer.msg("删除失败，请重新删除");
					}
                },
				error:function () {
					layer.msg("异步请求失败！");
                }
			});
        }
    function back() {
        history.back();
    }
</script>
</html>